﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Castle.MicroKernel.Registration;

namespace MoqContrib.AutoMock.Castle.Tests
{
    public class TestContainer : Castle.AutoMockContainer, All.Tests.IDoContainerStuff
    {
        #region IDoContainerStuff Members

        public IAutoMocker Helper
        {
            get { return Mock; }
            set { 
				_helper = value;
				Mock = _helper;
			}
        }

        public void RegisterServiceAs<TService>(TService instance) where TService : class
        {
            Register(Component.For<TService>().Instance(instance).LifeStyle.Singleton);
        }

		public void RegisterService<TService>() where TService : class
		{
			Register(Component.For<TService>().LifeStyle.Singleton);
		}

        public void RegisterServiceAs<TService, TComponent>()
            where TService : class
            where TComponent : TService
        {
            Register(Component.For<TService>().ImplementedBy<TComponent>());
        }

        public TService CreateTestSubject<TService>() where TService : class
        {
			return Mock.CreateTestSubject<TService>();
        }

		public TService ResolveService<TService>() where TService : class
		{
			return Resolve<TService>();
		}

		#endregion
	}
}
